<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    .kuang {
        width: 174px;
    }
</style>
<script src="../static/global.js"></script>
<body>
<!--优惠卷的添加-->
<div>
    <form class="layui-form layui-form-pane" id="session_relation_add_form" lay-filter="session_relation_add_form">
        <div class="layui-form-item">
            <label class="layui-form-label">活动标题</label>
            <div class="layui-input-inline">
                <input type="text" name="promotion_id" placeholder="请输入活動ID" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">活動場次ID</label>
            <div class="layui-input-inline">
                <input type="text" name="promotion_session_relation_id" placeholder="请输入开始时间" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">SKU_商品ID</label>
            <div class="layui-input-inline">
                <input type="text" name="sku_id" placeholder="请输入结束时间" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">秒杀价格</label>
            <div class="layui-input-inline">
                <input type="text" name="seckill_price" placeholder="请输入秒杀价格" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">秒杀数量</label>
            <div class="layui-input-inline">
                <input type="text" name="seckill_count" placeholder="请输入秒杀数量" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">限购数量</label>
            <div class="layui-input-inline">
                <input type="text" name="seckill_limit" placeholder="请输入限购数量" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="text" name="seckill_sort" placeholder="请输入" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="margin-left: 60px">
            <button type="submit" class="layui-btn" lay-submit="" id="session_relation_add"
                    lay-filter="session_relation_add">添加
            </button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </form>
</div>

<!--//第一步：编写模版。你可以使用一个script标签存放模板，如：-->
<script id="demo" type="text/html">
    <h3>{{ d.title }}</h3>
    <ul>
        {{# layui.each(d.list, function(index, item){ }}
        <li>
            <input type="text" name="seckill_sort" value={{ item.modname }} placeholder="请输入" class="layui-input">
            <input type="text" name="seckill_sort" value={{ item.alias }} placeholder="请输入" class="layui-input">
            <span>{{ item.modname }}</span>
            <span>{{ item.alias }}：</span>
            <span>{{ item.site || '' }}</span>
        </li>
        {{# }); }}
        {{# if(d.list.length === 0){ }}
        无数据
        {{# } }}
    </ul>
</script>

<!--//第二步：建立视图。用于呈现渲染结果。-->
<div id="view">111</div>
<script>


</script>

<script>

    layui.config({
        base: '../static/modules/'
    }).extend({
        numinput: 'numinput/numinput'
    }).use(['form','laytpl', 'layer', 'laydate', 'upload', 'numinput'], function () {
        let $ = layui.$;
        let laytpl = layui.laytpl;
        let layer = layui.layer;
        let form = layui.form;
        let laydate = layui.laydate;
        let upload = layui.upload;
        let numinput = layui.numinput;


        // 第三步：渲染模版
        var data = { //数据
            "title":"Layui常用模块"
            ,"list":[{"modname":"弹层","alias":"layer","site":"layer.layui.com"}]
        }
        var getTpl = demo.innerHTML
            ,view = document.getElementById('view');
        laytpl(getTpl).render(data, function(html){
            view.innerHTML = html;
        });



        //秒杀关联商品的新增信息
        form.on('submit(relation_add)', function () {
            let data = form.val('relation_add_form');
            console.log(data);
            $.ajax({
                url: glodate.serverZuul + "seckill_sku_relation/insert_admin_seckill_sku_relation_All",
                type: "post",
                dataType: "json",
                data: data,
                success: function (res) {
                    console.log(res);
                    if (res.code == 200) {
                        layer.msg("添加成功", {icon: 6});
                    } else {
                        layer.msg(res.msg, {icon: 5});
                    }
                    active.reload();
                }
            })
            return false;
        });


        //将日期直接嵌套在指定容器中
        laydate.render({
            elem: '#start_time'
            , type: 'datetime'
            , trigger: 'click'
        });
        laydate.render({
            elem: '#end_time'
            , type: 'datetime'
            , trigger: 'click'
        });
        laydate.render({
            elem: '#cre'
            , type: 'datetime'
            , trigger: 'click'
        });
        laydate.render({
            elem: '#enable_end_time'
            , type: 'datetime'
            , trigger: 'click'
        });
    })
</script>
</body>
</html>